//
//  DocotorConditionController.m
//  FastDoctor
//
//  Created by 王炯 on 16/7/9.
//  Copyright © 2016年 sc. All rights reserved.
//

#import "DocotorConditionController.h"

@interface DocotorConditionController ()

@property (nonatomic,strong)NSArray *dataArray;

@end

@implementation DocotorConditionController

static NSString *identify = @"doctorCell";

-(void)setDataArray:(NSArray *)dataArray
{
    _dataArray = dataArray;
    
    [self.tableView reloadData];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:identify];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSInteger section;
    
    if (self.num == 0)
    {
        section = 1;
    }
    else
    {
        section = self.dataArray.count;
    }
    
    return section;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    NSInteger row;
    
    if (self.num == 0)
    {
        row = self.dataArray.count;
    }
    else
    {
        row = 1;
    }
    
    return row;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
    
    NSString *getData;
    
    if (self.num == 0)
    {
        getData = self.dataArray[indexPath.row];
        cell.textLabel.text = [NSString stringWithFormat:@"就诊条件:%@",getData];
    }
    else
    {
        getData = self.dataArray[indexPath.section];
        cell.textLabel.text = [NSString stringWithFormat:@"医生简介:%@",getData];
        
        //添加箭头
        UIButton *arrowButton = [[UIButton alloc] init];
        
        [arrowButton setBackgroundImage:[UIImage imageNamed:@"arrow_right_black"] forState:UIControlStateNormal];
        
        [arrowButton sizeToFit];
        
        [cell.contentView addSubview:arrowButton];
        
        [arrowButton makeConstraints:^(MASConstraintMaker *make) {
           
            make.centerY.equalTo(cell.contentView.centerY);
            make.right.equalTo(cell.contentView.right).offset(-10);
            
        }];
        
        
    }
    
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 15;
}


//重写num的set方法
-(void)setNum:(NSInteger)num
{
    _num = num;
    
    if (num == 0)
    {
        self.dataArray = @[@"需要提供并发症",@"需要患者为首诊",@"需要提供个人史",@"需要提供疾病描述",@"需要提供病例",@"需要提供并发症",@"需要患者为首诊",@"需要提供个人史",@"需要提供疾病描述",@"需要提供病例"];
    }
    else
    {
        self.dataArray = @[@"德国",@"威尔士",@"法国",@"葡萄牙",@"冰岛"];
        
        self.tableView.rowHeight = 70;
    }
}


@end
